﻿using Glue;
using Xunit;

namespace GlueTests.AutoRelaterTests
{
    public class When_overriding_autorelating
    {
        private readonly Mapping<DomainPerson, GuiPerson> mapping;

        public class DomainPerson { public int Id { get; set; } }
        public class GuiPerson { public int Id { get; set; } }


        public When_overriding_autorelating()
        {
            mapping = new Mapping<DomainPerson, GuiPerson>();
            mapping.AutoRelateEqualNames();
            
        }

        [Fact]
        public void The_last_added_should_override_autorelated()
        {
            Assert.Equal(1,mapping.Relations.Count);
            Assert.Equal(RelationDirection.TwoWays,mapping.Relations.Get(domain=>domain.Id,gui=>gui.Id).Direction);
            mapping.RelateTowardsRight(master => master.Id, t => t.Id);
            Assert.Equal(1, mapping.Relations.Count);
            Assert.Equal(RelationDirection.TowardsRight, mapping.Relations.Get(domain => domain.Id, gui => gui.Id).Direction);
        }
    }
}
